import React,{ useState, useEffect,useCallback} from 'react';

function Callback(){


    const [name, setName] = useState('wuzi');
    
    useEffect(() => {
        setInterval(() => {
            setName(oldName => oldName + 'wuziz');
        },1000)
    }, []);

    console.log('父组件执行')

    const sayHello = useCallback(() =>{
        alert('我是父组件');
    },[]);
    
    const xxx =  'XXX'
    return(
        <div>
            <Children name={xxx} sayHello={sayHello} />
        </div>
    );
}


const Children = () => {
    console.log('子组件渲染')
        return <div>静态子组件</div>;
    
    };

    const PureChildren = React.memo(Children);


// class Children extends React.PureComponent {
//     render() {
//         console.log('子组件执行')
//         return <div>静态子组件</div>
//     }
// }

export default Callback;